package com.zlc.workflow.core.business.controller;

import com.zlc.common.core.business.model.vo.StoneReimbursementProcessVo;
import com.zlc.workflow.core.business.service.ReimbursementService;
import com.zlc.workflow.core.instance.model.EventParam;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Api(tags = "报销流程api")
@RestController
@Slf4j
@RequestMapping("/api/business/reimbursement")
public class ReimbursementController {

    @Autowired
    private ReimbursementService reimbursementService;

    @ApiOperation(value = "保存报销单信息")
    @GetMapping(value = "findByProcessInstanceId")
    public StoneReimbursementProcessVo findByProcessInstanceId(@RequestParam(value = "processInstanceId") String processInstanceId) {
        return reimbursementService.findByProcessInstanceId(processInstanceId);
    }

    @ApiOperation(value = "保存报销单信息")
    @PostMapping(value = "saveReimbursement")
    public void saveReimbursement(@RequestBody StoneReimbursementProcessVo reimburse) {
        reimbursementService.saveReimbursement(reimburse);
    }

    @ApiOperation(value = "报销流程启动处理")
    @PostMapping(value = "beforeStartProcess")
    public void beforeStartProcess(@RequestBody EventParam param) {
        reimbursementService.beforeStartProcess(param);
    }

    @ApiOperation(value = "报销流程结束处理")
    @PostMapping(value = "finishProcess")
    public void finishProcess(@RequestBody EventParam param) {
        reimbursementService.finishProcess(param);
    }

    @ApiOperation(value = "保存报销流程终止处理报销单信息")
    @PostMapping(value = "terminationProcess")
    public void terminationProcess(@RequestBody EventParam param) {
        reimbursementService.terminationProcess(param);
    }

    @ApiOperation(value = "报销流程节点到达处理")
    @PostMapping(value = "nodeArrive")
    public void nodeArrive(@RequestBody EventParam param) {
        reimbursementService.nodeArrive(param);
    }
}
